package com.ruyuan.eshop.manager.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @author pwd
 * @version 1.0
 */
@Configuration
@EnableSwagger2
public class SwaggerConfig {

    /**
     * api接口文档
     *
     * @return
     */
    @Bean
    public Docket apiDoc() {

        return new Docket(DocumentationType.SWAGGER_2)
                .groupName("manager-api")
                .pathMapping("/")
                .enable(true)
                //配置文档的元信息
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.ruyuan.eshop.manager"))
                .paths(PathSelectors.ant("/**"))
                .build();


    }

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("儒猿eshop平台端管理系统")
                .description("接口文档")
                .contact(new Contact("pwd", "http://www.ruyuan2020.com", "pwd@ruyuan.com"))
                .version("v1.0")
                .build();
    }

}